const { Controller } = require('egg')
const dayjs = require('dayjs')

class ApiController extends Controller {
  /**
   * @api {get} /hs/result [核酸] 结果
   * @apiGroup Hs
   * @apiDescription 态势总览-核酸检测结果统计
   * 
   * @apiParam {String} [scope=day] 统计范围 day（天）、week（周）、month（月）
   * 
   * @apiSuccessExample {json} Success-Response:
    {
        "code": 0,
        "msg": "success",
        "data": [
            {
                "total": 30,// 核酸已采人数
                "positive": 12, // 阳性
                "negative": 18, // 阴性
                "label": "乡镇1" // 乡镇
                "ycrs": 0, // 应采人数
                "wcrs": 0, // 未采人数
                "percen": 0 // 采集率
            },
        ]
    }
   */
  async hsResult() {
    const { ctx } = this
    const { query } = ctx
    const scope = query.scope || 'day'

    const returnData = await this.service.trackData.getData(`${scope}_town_hs_result`)

    ctx.body = {
      code: 0,
      msg: 'success',
      data: returnData,
    }
  }
}

module.exports = ApiController
